import java.nio.file.Path;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author dreamcatcher
 * @date 2022/3/2 22:25
 * 结巴去重
 */
public class RegExp14 {
    public static void main(String[] args) {
        String content = "我...我要...学学学...java";
        String s = "\\.";
        String s1 = "(.)\\1+";
        System.out.println(content);
        Pattern pattern = Pattern.compile(s);
        Matcher matcher = pattern.matcher(content);
        //将.号删除
        content = matcher.replaceAll("");
        System.out.println(content);
        //将连续的重复字替换为一个
        pattern = Pattern.compile(s1);
        matcher = pattern.matcher(content);
        content = matcher.replaceAll("$1");
        System.out.println(content);

    }
}
